import 'package:favoritecate/core/model/meal_model.dart';
import 'package:favoritecate/core/viewmodel/favor_meal_viewmodel.dart';
import 'package:favoritecate/ui/pages/detail/meal_detail_content.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class FYMealDetailPage extends StatelessWidget {
  static const String routeName = 'MealDetailPage';

  @override
  Widget build(BuildContext context) {
    final model = ModalRoute.of(context).settings.arguments as FYMealModel;
    return Scaffold(
      appBar: AppBar(title: Text('${model.title}'),),
      body: MealDetailContent(model),
      floatingActionButton: Consumer<FYFavorMealViewModel>(
        builder: (ctx,favor,child){
          //判断是否已收藏
          IconData data = favor.isFavor(model) ? Icons.favorite : Icons.favorite_border;
          Color color = favor.isFavor(model) ? Colors.red : Colors.black;
          return FloatingActionButton(
            child: Icon(data,color: color,),
            onPressed: (){
              favor.handleMeal(model);
            },
          );
        },
      )
    );
  }
}
